import { Form } from "antd";
import { Select } from "@/views/components/PrefixPlaceholder";
import { STOCK_RULE } from "@/views/utils/constant";
import { useCallback, useEffect, useState, useRef } from "react";
import { CommonModal } from "@/views/components/CommonModal";
const PresentationRuleModal = ({ visible, checkedRows, handleCancel, fetchList }) => {
	const [form] = Form.useForm();
	const [value, setValue] = useState("1");

	const onOk = () => {
		localStorage.setItem("sotckRule", value);
		fetchList({ needHideZero: value });
		onCancel();
	};
	useEffect(() => {
		setValue(localStorage.getItem("sotckRule"));
	}, [visible]);
	const onCancel = () => {
		handleCancel();
		form.resetFields();
	};

	return (
		<CommonModal
			title={{ title: "展示规则" }}
			className="views-table-dialog"
			visible={true}
			onOk={onOk}
			onCancel={onCancel}
			width="500px"
			minHeight="150px"
		>
			<Form form={form}>
				<Select
					className="width-full"
					value={value ? value : "1"}
					onChange={e => setValue(e)}
					placeholder="请选择商品是否隐藏"
					options={STOCK_RULE}
				/>
			</Form>
		</CommonModal>
	);
};

export default PresentationRuleModal;
